package cn.edu.scau.cmi.maikejian.Singleton;




import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class Controller {
	public boolean SingLeton = true; //flase 表示多例，ture 单例
    @FXML
    private Button button;
    
    @FXML
    private Button button2;

    @FXML
    private TextField textfield;

    @FXML
    private TextArea textarea;

    @FXML
    void onAction(ActionEvent event) {
    	   
           Chairman chairman = Chairman.getInstance(textfield.getText());
           chairman.ChangeName(textfield.getText());
           if(SingLeton&&chairman.getName()!=null) {
        	   if(chairman.getCount()==0)
        	   {
               textarea.appendText(chairman.getName()+"cn.edu.scau.cmi.maikejian.Singleton@234ed34\n");
               chairman.add();      
        	   }
           }
           else if(chairman.getCount()<10)
           {
        	   textarea.appendText(chairman.getName()+"cn.edu.scau.cmi.maikejian.Marshal@234ed34\n");
               chairman.add();  
           }
           
    }
     @FXML
     void changce(ActionEvent event) {
           if(SingLeton) {
        	   SingLeton = false;
               button.setText("多例创建"); 
               }
           else {
        	   SingLeton = true;
               button.setText("单例创建"); 
        	   
           }
           
    }
    
}
